package com.tedu.charging.service.bill.controller;

import com.tedu.charging.common.pojo.param.ChargingProgressParam;
import com.tedu.charging.common.pojo.web.ServerResult;
import com.tedu.charging.common.pojo.vo.ChargeProgressVO;
import com.tedu.charging.service.bill.service.IChargingBillProgressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;


/**
 * 充电进度Controller
 *
 * @author tedu
 * @date 2023-06-15
 */
@RestController
@RequestMapping("/charge/progress")
@CrossOrigin
public class ChargingBillProgressController {
    @Autowired
    private IChargingBillProgressService chargingBillPrgressService;

    //手机端点结束充电，获取订单数据
    @GetMapping(value = "/{id}")
    public ServerResult<ChargeProgressVO> getInfo(@PathVariable("id") String billId) {
        ChargeProgressVO chargeProgressVO = chargingBillPrgressService.selectChargingBillPrgressById(billId);

        return ServerResult.success(chargeProgressVO);
    }

    //设备上传充电过程数据，有的设备能接收电费等数据，做计费处理
    @GetMapping("/updateProgress")
    public ServerResult<ChargeProgressVO> updateProgress(ChargingProgressParam chargingProgressParam) throws IOException {
        ChargeProgressVO chargeProgressVO = chargingBillPrgressService.updateProgress(chargingProgressParam);
        return ServerResult.success(chargeProgressVO);
    }

}
